import 'package:flutter/material.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/page/auto_makers/shop_home/order_widget/check_type.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';

//询价列表项
// ignore: must_be_immutable
class EnquiryItem extends StatefulWidget {
   int checkIndex; //初始索引
   ValueChanged<int> onCheckUpdate;  //选中回调
   String typeTitle;//订单状态

   EnquiryItem({Key key, this.checkIndex,this.onCheckUpdate,this.typeTitle = ""}) : super(key: key);
  @override
  _EnquiryItemState createState() => _EnquiryItemState();
}

class _EnquiryItemState extends State<EnquiryItem> {
  List<String> typeList = ["原厂原包", "品牌", "拆车", "OEM"];

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.all(setWidth(15)),
      margin: EdgeInsets.only(bottom: setWidth(12)),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                height: setWidth(90),
                width: setWidth(90),
                decoration: BoxDecoration(
                    color: Color(0xffC4C4C4),
                    borderRadius: BorderRadius.circular(6)),
              ),
              SizedBox(
                width: setWidth(10),
              ),
              Expanded(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      child: Text(
                        "前挡泥板-右后翼子板",
                        style: TextStyle(
                            color: Color(0xff323232), fontSize: setSp(15)),
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                      ),
                    ),
                    SizedBox(
                      height: setWidth(5),
                    ),
                    Container(
                      child: Text(
                        "零件编号：50260TJFJ01",
                        style: TextStyle(
                            color: Color(0xff989898), fontSize: setSp(14)),
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                      ),
                    ),
                    SizedBox(
                      height: setWidth(19),
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Container(
                          child: Text("我的报价",
                              style: TextStyle(
                                  color: Color(0xff323232),
                                  fontSize: setSp(12))),
                        ),
                        SizedBox(
                          width: setWidth(5),
                        ),
                        Expanded(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: [
                              RichText(
                                  maxLines: 1,overflow: TextOverflow.ellipsis,
                                  text: TextSpan(
                                      children: [
                                        TextSpan(
                                          text: "￥",style: TextStyle(color: YTTheme.theme,fontSize: setSp(15),fontWeight: FontWeight.w600),

                                        ),
                                        TextSpan(
                                          text: "5895.00",style: TextStyle(color: YTTheme.theme,fontSize: setSp(20),fontWeight: FontWeight.w600),

                                        ),

                                      ]
                                  )),

                              Container(
                                child: Text("x1",style: TextStyle(color: Color(0xff323232),fontSize: setSp(14))),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                    SizedBox(
                      height: setWidth(35),
                    ),
                  ],
                ),
              ),
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  Container(
                    margin: EdgeInsets.only(top: setWidth(6)),
                    child: Text(
                      "属性:",
                      style: TextStyle(
                          color: Color(0xff666666), fontSize: setSp(14)),
                    ),
                  )
                ],
              ),
              SizedBox(
                width: setWidth(5),
              ),
              //属性
              Expanded(
                  child: Container(
                    child: Wrap(
                      spacing: setWidth(5),
                      runSpacing: setWidth(5),
                      children: typeList
                          .asMap()
                          .map((key, value) {
                        return MapEntry(key, CheckType(
                          index: key,
                          title: value,
                          checkIndex: widget.checkIndex,
                          check:(){
                            setState(() {
                              widget.checkIndex = key ;
                            });
                            widget.onCheckUpdate(key);
                          },
                        ));
                      })
                          .values
                          .toList(),
                    ),
                  )),
              SizedBox(
                width: setWidth(5),
              ),
              Container(
                margin: EdgeInsets.only(top: setWidth(6)),
                child: Text(
                 widget.typeTitle,
                  style: TextStyle(
                      color: Color(0xffFF4D4D), fontSize: setSp(14)),
                ),
              )
            ],
          )
        ],
      ),
    );
  }

}



